package com.alm.token.ui.activity;

import android.support.v4.app.Fragment;
import android.view.View;

import com.alm.token.R;
import com.alm.token.base.BaseActivity;
import com.alm.token.ui.persenter.MyPreenter;
import com.alm.token.ui.viewpagefragment.CandyListPageFrag;
import com.alm.token.ui.viewpagefragment.CorwdListPageFrag;
import com.alm.token.ui.viewpagefragment.EggRankingPageFrag;
import com.alm.token.ui.viewpagefragment.EggWalletLog2PageFrag;
import com.alm.token.ui.viewpagefragment.EggWalletLogPageFrag;
import com.alm.token.ui.viewpagefragment.MessageBasePageFrag;
import com.alm.token.ui.viewpagefragment.MessageNoticePageFrag;
import com.alm.token.ui.viewpagefragment.TransformListPageFrag;
import com.alm.token.ui.viewpagefragment.TurnOutListPageFrag;
import com.alm.token.ui.viewpagefragment.VipOredrListPageFrag;
import com.alm.token.utils.ActionBarHelper;
import com.alm.token.utils.ItemTitlePagerAdapter;
import com.alm.token.utils.LanguageUtils;
import com.alm.token.widget.CustomTabLayout;
import com.alm.token.widget.NoScrollViewPager;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

public class VipOrderListActivity extends BaseActivity {
    @BindView(R.id.tab)
    CustomTabLayout tab;
    @BindView(R.id.view_pager)
    NoScrollViewPager viewPager;
    private int intentType = 0;

    @Override
    protected MyPreenter initPreenter() {
        return null;
    }

    @Override
    protected int getContentViewId() {

        intentType = getIntent().getIntExtra("intentType", 0);
        if (intentType == 4||intentType == 6) {
            return R.layout.activity_candylist_layout;
        }
        return R.layout.activity_message;
    }

    @Override
    protected void initVariables() {
        intentType = getIntent().getIntExtra("intentType", 0);
        if (intentType == 1) {
            new ActionBarHelper(this).setTitle(getString(R.string.title_hint_item16));
        } else if (intentType == 2) {
            new ActionBarHelper(this).setTitle(getString(R.string.title_hint_item17));
        } else if (intentType == 3) {
            new ActionBarHelper(this).setTitle(getString(R.string.title_hint_item18));
        } else if (intentType == 4) {
            String seprite = LanguageUtils.getSetIndex() == 1 ? "" : " ";
            new ActionBarHelper(this).setTitle(getString(R.string.app_hint_redenvelope) + seprite + getString(R.string.banner_hint_jilu));
        } else if (intentType == 5) {
            int type = getIntent().getIntExtra("INTENT_EGGLOG_TYPE", 2);
            new ActionBarHelper(this).setTitle( type == EggWalletLogPageFrag.INTENT_EGGLOG_MYEGG ? getString(R.string.easteregg_hint_myegg_title) :
                    type == EggWalletLogPageFrag.INTENT_EGGLOG_MYSMIO ? getString(R.string.easteregg_hint_mysmio) : getString(R.string.easteregg_hint_mysmiojili));
        } else if (intentType == 6) {
            new ActionBarHelper(this).setTitle(  getString(R.string.egg_hint_buylog) );
        } else if (intentType == 7) {
            int type = getIntent().getIntExtra("INTENT_EGGLOG_TYPE", 2);
            new ActionBarHelper(this).setTitle( type == EggWalletLog2PageFrag.INTENT_EGGLOG_MYEGGTOKEN ? getString(R.string.easteregg_hint_myaward): getString(R.string.easteregg_hint_mysmiojili));
        } else {
            new ActionBarHelper(this).setTitle(getString(R.string.title_hint_item19));
        }

    }

    @Override
    protected void initViews() {
        initTab();
    }

    private void initTab() {
        tab.setVisibility(View.GONE);
        String[] tabNames = {getString(R.string.platform_hint_msg)};
        List<Fragment> fragmentList = new ArrayList<>();
        if (intentType == 1) {
            fragmentList.add(TransformListPageFrag.newInstance());
        } else if (intentType == 2) {
            fragmentList.add(TurnOutListPageFrag.newInstance());
        } else if (intentType == 3) {
            fragmentList.add(CorwdListPageFrag.newInstance());
        } else if (intentType == 4) {
            fragmentList.add(CandyListPageFrag.newInstance());
        } else if (intentType == 5) {
            fragmentList.add(EggWalletLogPageFrag.newInstance(getIntent().getIntExtra("INTENT_EGGLOG_TYPE", 2)));
        } else if (intentType == 6) {
            fragmentList.add(EggRankingPageFrag.newInstance());
        }else if (intentType == 7) {
            fragmentList.add(EggWalletLog2PageFrag.newInstance(getIntent().getIntExtra("INTENT_EGGLOG_TYPE", 2)));
        }  else {
            fragmentList.add(VipOredrListPageFrag.newInstance());
        }

        tab.setItemLayout(R.layout.item_message_tab);
        tab.setTabNames(tabNames);
        tab.notifyChange();
        tab.setViewPager(viewPager);


        viewPager.setAdapter(new ItemTitlePagerAdapter(getSupportFragmentManager(),
                fragmentList, tabNames));
        viewPager.setOffscreenPageLimit(1);
    }

    @Override
    protected void loadData() {

    }

    @Override
    public void onClick(View v) {

    }

}
